package org.liuchang.util;

import java.awt.Dimension;
import java.awt.Image;
import java.net.URL;

import javax.swing.ImageIcon;

import org.liuchang.MainFrame;
import org.liuchang.login.LoginPanel;
import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon;
import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;

public class PublicUtil {

	public static Image getImage(String path) {
		URL url = LoginPanel.class.getClass().getResource(path);
		Image image = new ImageIcon(url).getImage();
		return image;
	}

	// 根据图片的地址获取该图片，返回ResizableIcon
	public static ResizableIcon getResizableIconFromResource(String resource) {
		return ImageWrapperResizableIcon.getIcon(MainFrame.class
				.getClassLoader().getResource(resource), new Dimension(48, 48));
	}
}
